package com.example.java_chatroom_redis_rabbitmq.service;

import com.example.java_chatroom_redis_rabbitmq.mapper.SessionMapper;
import com.example.java_chatroom_redis_rabbitmq.model.Session;
import com.sun.org.apache.bcel.internal.generic.PUSH;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SessionService {
    @Autowired
    private SessionMapper sessionMapper;

    public List<Session> getSessionListByUserId(Integer userId) {
        return sessionMapper.getSessionListByUserId(userId);
    }

    public Session getSessionInfoBySessionId(Integer sessionId) {
        return sessionMapper.getSessionInfoBySessionId(sessionId);
    }

    public Integer createSession(Session session) {
        return sessionMapper.createSession(session);
    }

    public Integer createSessionUser(Integer sessionId,Integer userId,Integer friendId) {
        return sessionMapper.createSessionUser(sessionId,userId,friendId);
    }

    public List<Integer> getUserIdsBySessionId(Integer sessionId,Integer userId) {
        return sessionMapper.getUserIdsBySessionId(sessionId,userId);
    }

    public Integer updateSession(Integer sessionId,String lastMessage) {
        return sessionMapper.updateSession(sessionId,lastMessage);
    }
}
